﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Web.Mvc;

namespace PessModel
{


    [MetadataType(typeof(ExpertJudgeMetaData))]
    public partial class ExpertJudge
    {
        [Required]
        [DataType(DataType.EmailAddress)]
        [Display(Name = "Email address")]
        public string Email { get; set; }

        //[Required]
        //[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
        //[DataType(DataType.Password)]
        //[Display(Name = "Password")]
        //public string Password { get; set; }

        
    }

    public class ExpertJudgeMetaData
    {
        [Required]
        [Display(Name = "Name")]
        public string RealName { get; set; }
    }

    [MetadataType(typeof(ArchiveMetaData))]
    public partial class Archive
    {
        [DisplayName("ID")]
        public string CalculatedSerialNumber
        {
            get
            {
                /*return string.Format("Y{0}A{1}S{2}V{3}",
                    this.Subject.Activity.AdminYear.Value.Year,
                    this.Subject.ActivityID,
                    this.SubjectID,
                    this.ID
                    );*/
                return string.Format("Y{0}C{1}T{2}P{3}",
                    this.Subject.Activity.AdminYear.Value.Year,
                    this.CountyCode,
                    this.Subject.TrackID,
                    this.ID
                    );
            }
        }
        public string Name
        {
            get
            {
                return LastName + ", " + FirstName;
            }
        }
        [DisplayName("Contact Address")]
        public string ContactAddress
        {
            get
            {
                return Address1 + " " + Address2 + ", " + City + ", " + StateProvince + ", " + ZipCode + ", " + Country;
            }
        }
        public ArchiveStatus StatusName
        {
            get
            {
                if (Status != null)
                    return (ArchiveStatus)Status;
                else
                    return ArchiveStatus.Submitted;
            }
        }
        public ArchivePaperStatus PaperStatusName
        {
            get
            {
                if (PaperStatus != null)
                    return (ArchivePaperStatus)PaperStatus;
                else
                    return ArchivePaperStatus.Pending;
            }
        }
        public IList<PAuthor> PAuthorsInOrder
        {
            get
            {
                return PAuthors.OrderByDescending(pa=>pa.Type).ThenBy(pa => pa.Order).ToList();
            }
        }
        public PaperAcceptanceStatus ChairPaperStatusName
        {
            get
            {
                if (ChairPaperStatus != null)
                    return (PaperAcceptanceStatus)ChairPaperStatus;
                else
                    return PaperAcceptanceStatus.Unknown;
            }
        }
       
    }

    public class ArchiveMetaData
    {
        [DataType(DataType.MultilineText)]
        [AllowHtml]
        //[UIHint("tinymce_half")]
        [Required]
        [DisplayName("Short Description")]
        public string SchoolComment { get; set; }

        [DataType(DataType.MultilineText)]
        [AllowHtml]
        //[UIHint("tinymce_full")]
        [Required]
        [DisplayName("Abstract")]
        public string CountyEBComment { get; set; }
        [DisplayName("Primary Keywords")]
        [Required]
        public string PrimaryKeyword { get; set; }
        [DisplayName("Secondary Keywords")]
        public string SecondaryKeyword { get; set; }
        [DisplayName("E-mail Address")]
        [Required]
        [DataType(DataType.EmailAddress, ErrorMessage = "E-mail is not valid")]
        public string EMail { get; set; }
        [DisplayName("First Name")]
        [Required]
        public string FirstName { get; set; }
        [Required]
        [DisplayName("Last Name")]
        public string LastName { get; set; }
        [Required]
        [DisplayName("Phone Number")]
        public string PhoneNumber { get; set; }
        [Required]
        [DisplayName("Affiliation")]
        public string SchoolName { get; set; }
        [DisplayName("Zip/Postal Code")]
        [Required]
        public string ZipCode { get; set; }
        [DisplayName("State/Province")]
        [Required]
        public string StateProvince { get; set; }
        [DisplayName("Title")]
        [Required]
        public string ProjectTitle { get; set; }
        [DisplayName("Topic")]
        [Required]
        public int SubjectID { get; set; }
        [DisplayName("Format")]
        [Required]
        public string CountyCode { get; set; }
        [Required]
        public string Address1 { get; set; }
        public string Address2 { get; set; }
        [Required]
        public string City { get; set; }
        [Required]
        public string Country { get; set; }
        [DisplayName("Professional Title")]
        public string ProfessionalTitle { get; set; }
        [DisplayName("Tech Requirements")]
        public string TechnologyRequirements { get; set; }
        [DisplayName("Suggested Category")]
        public string SuggestedCategory { get; set; }
        [DisplayName("Fax")]
        public string FAX { get; set; }

    }

    [MetadataType(typeof(RuleMetaData))]
    public partial class Rule
    {
    }
    public class RuleMetaData
    {
        [Required]
        public string Name { get; set; }
        [Required]
        [Range(0,Int32.MaxValue)]
        public int Value { get; set; }
        [DataType(DataType.MultilineText)]
        public string Description { get; set; }
    }

    [MetadataType(typeof(PaperRuleMetaData))]
    public partial class PaperRule
    {
    }
    public class PaperRuleMetaData
    {
        [Required]
        public string Name { get; set; }
        [Required]
        [Range(0, Int32.MaxValue)]
        public int Value { get; set; }
        [DataType(DataType.MultilineText)]
        public string Description { get; set; }
    }

    [MetadataType(typeof(ActivityMetaData))]
    public partial class Activity
    {
    }
    public class ActivityMetaData
    {
        //[DataType(DataType.MultilineText)]
        [AllowHtml]
        [UIHint("tinymce_full")]
        public string Description { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> StartDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> DueDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:yyyy}", ApplyFormatInEditMode = false)]
        public Nullable<System.DateTime> AdminYear { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> ReviewStartDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> ReviewDueDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> UploadStartDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> UploadDueDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> PaperStartDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> PaperDueDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> PaperReviewStartDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> PaperReviewDueDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> FinalPaperStartDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}")]
        public Nullable<System.DateTime> FinalPaperDueDate { get; set; }

    }

    [MetadataType(typeof(TrackMetaData))]
    public partial class Track
    {
        public string ShortTitle
        {
            get
            {
                if (this.Title.Length > 7)
                    return this.Title.Substring(0, 7)+"...";
                else
                    return this.Title;
            }
        }
    }
    public class TrackMetaData
    {
    }

    [MetadataType(typeof(PAuthorMetaData))]
    public partial class PAuthor
    {
        public string Name
        {
            get
            {
                return LastName + ", " + FirstName;
            }
        }
        public AuthorType TypeName
        {
            get
            {
                    return (AuthorType)this.Type;
            }
        }
    }
    public class PAuthorMetaData
    {
        [DisplayName("Email Address")]
        public string EMail { get; set; }
        [DisplayName("Last Name")]
        public string LastName { get; set; }
        [DisplayName("First Name")]
        public string FirstName { get; set; }

    }

    [MetadataType(typeof(Registration))]
    public partial class Registration
    {
        public decimal TotalAmountRMB
        {
            get
            {
                decimal totalamount = 0;
                foreach(var item in this.RegistrationOptions)
                {
                    totalamount += item.EarlyDate >= DateTime.Now.Date ? item.EarlyFeeRMB : item.RegularFeeRMB;
                }
                return totalamount;
            }
        }

        public decimal TotalAmountUSD
        {
            get
            {
                decimal totalamount = 0;
                foreach (var item in this.RegistrationOptions)
                {
                    totalamount += item.EarlyDate >= DateTime.Now.Date ? item.EarlyFeeUSD : item.RegularFeeUSD;
                }
                return totalamount;
            }
        }

    }

}
